import React, { Suspense } from 'react'
import { BrowserRouter, useRoutes } from 'react-router-dom'
import { Router_List } from './routes'
import BeforeEachRouter from '../components/beforeEachRouter'
const Router: React.FC = () => {
  // 处理路由表， 添加拦截
  const permiss_router_liust = Router_List.map(v => {
    return {
      ...v,
      /* 路由拦截前置守卫 */ 
      element: <BeforeEachRouter v={v}></BeforeEachRouter>
    }
  })
  const RouterView = () => useRoutes(permiss_router_liust)
  return (
    <BrowserRouter>
      <Suspense>
        <RouterView></RouterView>
      </Suspense>
    </BrowserRouter>
  )
}


export default Router


